﻿<Menu Items="@Items" />

@code {
    private IEnumerable<MenuItem> Items { get; set; } = Enumerable.Empty<MenuItem>();

    private IEnumerable<MenuItem> GetItems()
    {
        var ret = new List<MenuItem>
        {
            new MenuItem() { Text = "导航一" },
            new MenuItem() { Text = "导航二", IsActive = true },
            new MenuItem() { Text = "导航三" }
        };

        ret[1].AddItem(new MenuItem() { Text = "子菜单一" });
        ret[1].AddItem(new MenuItem() { Text = "子菜单二" });
        ret[1].AddItem(new MenuItem() { Text = "子菜单三" });

        ret[1].Items.ElementAt(0).AddItem(new MenuItem() { Text = "孙菜单1一" });
        ret[1].Items.ElementAt(0).AddItem(new MenuItem() { Text = "孙菜单1二" });

        ret[1].Items.ElementAt(1).AddItem(new MenuItem() { Text = "孙菜单2一" });
        ret[1].Items.ElementAt(1).AddItem(new MenuItem() { Text = "孙菜单2二" });

        ret[1].Items.ElementAt(1).Items.ElementAt(1).AddItem(new MenuItem() { Text = "曾孙菜单一" });
        ret[1].Items.ElementAt(1).Items.ElementAt(1).AddItem(new MenuItem() { Text = "曾孙菜单二" });

        ret[1].Items.ElementAt(1).Items.ElementAt(1).Items.ElementAt(1).AddItem(new MenuItem() { Text = "曾曾孙菜单一" });
        ret[1].Items.ElementAt(1).Items.ElementAt(1).Items.ElementAt(1).AddItem(new MenuItem() { Text = "曾曾孙菜单二" });

        return ret;
    }

    /// <summary>
    /// OnInitialized 方法
    /// </summary>
    protected override void OnInitialized()
    {
        base.OnInitialized();
        Items = GetItems();
    }
}
